package config

import (
	"github.com/spf13/viper"
)

const (
	defaultGrpcPort          = "9000"
	defaultHttpPort          = "9001"
	defaultAddr              = "127.0.0.1"
	defaultMicroservicesName = "service"
)

// 默认配置
var defaultConfigMap = map[string]interface{}{
	// service
	"SERVICE.NAME":       defaultMicroservicesName,
	"SERVICE.RUNMODE":    "production",
	"SERVICE.ADDR":       defaultAddr,
	"SERVICE.GRPCPORT":   defaultGrpcPort,
	"SERVICE.HTTPPORT":   defaultHttpPort,
	"SERVICE.KEY":        "Rtg8BPKNEf2mB4ddvKONGPZZQSaJWNLijxR42qRgq0iBb5",
	"SERVICE.COMMONNAME": "strv.cn",

	// db
	"DB.CONNECTION": "mysql",
	"DB.HOST":       "127.0.0.1",
	"DB.PORT":       "33060",
	"DB.DATABASE":   defaultMicroservicesName,
	"DB.USERNAME":   "root",
	"DB.PASSWORD":   "password",

	//log
  "LOG.LEVEL":   1,
	"LOG.TIMEFORMAT":   "2006-01-02T15:04:05Z07:00",
}

// 设置配置默认值
func setupDefaultConfig() {
	for k, v := range defaultConfigMap {
		viper.SetDefault(k, v)
	}
}
